package Java.BlackHorse.Thread.ThreadPoll;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPollDemo {
    /*
    *创建一个没有上限的线程池
    * public static ExecutorService newCachedThreadPoll()
    *
    *创建一个有上限的线程池
    * public static ExecutorService newFixedThreadPool (int nThreads)
    * */
    public static void main(String[] args) {
        MyRunnable mr = new MyRunnable();

        //创建一个没有上限的线程池
//        ExecutorService poll = Executors.newCachedThreadPool();

        //创建一个有上限的线程池
        ExecutorService poll = Executors.newFixedThreadPool(2);

        poll.submit(new MyRunnable());
        poll.submit(new MyRunnable());
        poll.submit(new MyRunnable());
        poll.submit(new MyRunnable());
        poll.submit(new MyRunnable());
        poll.submit(new MyRunnable());

    }
}
